package model

import (
	"database/sql"
	"time"
)

type CalendarEvent struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	Name                    string
	Description             sql.NullString
	UserId                  sql.NullInt64
	User                    ResUsers
	Location                sql.NullString
	VideocallLocation       sql.NullString
	Privacy                 string
	ShowAs                  string
	Active                  bool
	Start                   time.Time
	Stop                    time.Time
	Allday                  bool
	StartDate               time.Time
	StopDate                time.Time
	Duration                float64
	ResId                   sql.NullInt64
	ResModelId              sql.NullInt64
	ResModel                sql.NullString
	Recurrency              bool
	RecurrenceId            sql.NullInt64
	FollowRecurrence        bool
	//Type                    string
	//Meeting      sql.NullString
	//Notes        string
	//RoomId       sql.NullInt64
	//Room         CalendarRoom
	//DepartmentId sql.NullInt64
	//Url                     sql.NullString
	//Year                    string
	//DateDay                 int
	//Month                   string
	//Hour                    string
	//WeekStart               string
	//Week                    int
	//Quarter                 string
	//Progress                int64
	//State                   string
	//OpportunityId sql.NullInt64
	Tags     []CalendarEventType `gorm:"many2many:meeting_category_rel;joinForeignKey:event_id;joinReferences:type_id"`
	Partners []ResPartner        `gorm:"many2many:calendar_event_res_partner_rel;joinForeignKey:calendar_event_id;joinReferences:res_partner_id"`
	Alarms   []CalendarAlarm     `gorm:"many2many:calendar_alarm_calendar_event_rel;joinForeignKey:calendar_event_id;joinReferences:calendar_alarm_id"`
}

type CalendarRoom struct {
	ResCommon
	Name      string
	UserId    int64
	Max       int
	Sequence  int64
	OpenHours string
	Note      string
	State     string
}

type CalendarEventLine struct {
	ResCommon
	OrderId   int64
	Sequence  int64
	Name      string
	UserId    int64
	Date      time.Time
	Year      string
	Month     string
	Hour      string
	WeekStart string
	Week      string
	Quarter   string
	State     string
}

type CalendarEventResPartnerRel struct {
	ResPartnerId    int64
	ResPartner      ResPartner
	CalendarEventId int64
}

type CalendarAttendee struct {
	ResCommon
	EventId      int64
	PartnerId    int64
	CommonName   string
	AccessToken  string
	State        string
	Availability string
}

type CalendarRecurrence struct {
	ResCommon
	Name        string
	BaseEventId int64
	EventTz     string
	Rrule       string
	RruleType   string
	EndType     string
	Interval    int
	Count       int
	Mon         bool
	Tue         bool
	Wed         bool
	Thu         bool
	Fri         bool
	Sat         bool
	Sun         bool
	MonthBy     string
	Day         int
	Weekday     string
	Byday       string
	Until       sql.NullTime
}

type CalendarEventType struct {
	Id         int64
	Name       string
	Color      int64
	CreateUid  int64
	CreateDate time.Time
	WriteUid   int64
	WriteDate  time.Time
}

type CalendarAlarmCalendarEventRel struct {
	CalendarEventId int64
	CalendarAlarmId int64
}

type CalendarFilters struct {
	ResCommon
	UserId         int64
	PartnerId      int64
	Active         bool
	PartnerChecked bool
}

type CalendarAlarm struct {
	ResCommon
	Name            string
	AlarmType       string
	Duration        int64
	int64erval      string
	DurationMinutes int64
	MailTemplateId  int64
	Body            string
	SmsTemplateId   int64
}

type ResourceCalendar struct {
	ResCommon
	Name             string
	Active           bool
	CompanyId        int64
	HoursPerDay      float64
	Tz               string
	TwoWeeksCalendar sql.NullBool
}
type ResourceCalendarAttendance struct {
	ResCommon
	Name       string
	Dayofweek  string
	DateFrom   sql.NullTime
	DateTo     sql.NullTime
	HourFrom   float64
	HourTo     float64
	CalendarId int64
	DayPeriod  string
}

// HrAttendanceOvertime 加班时间
type HrAttendanceOvertime struct {
	ResCommon
	EmployeeId   int64
	Date         time.Time
	Duration     float64
	DurationReal float64
	Adjustment   bool
}

type MeetingCategoryRel struct {
	EventId int64
	TypeId  int64
	Type    CalendarEventType
}
